/*
 * 
 * Copyright 2011 visual-analysis-of-cancer.
 * This file is part of visual-analysis-of-cancer.
 * 
 * visual-analysis-of-cancer is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * visual-analysis-of-cancer is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with kOSMik.  If not, see <http://www.gnu.org/licenses/>.
 *  
 * visual-analysis-of-cancer:
 * An tool to analye the WHO and GLOBOCAN cancer data.
 * http://code.google.com/p/visual-analysis-of-cancer/
 * 
 * 
 * 
 * Authors: Erik Sniegula, Johannes Dahlke
 * 
 * Module:  Programming in Processing for Visual Analytics
 * Group:   20
 * 
 * Created: Aug. 2011
 * Version: 1.0
 *
 */
 




package de.fuberlin.processing.who.cancer.gui;

import java.util.Observable;
import java.util.Observer;

import processing.core.PApplet;
import processing.core.PImage;
import controlP5.ControlCanvas;
import controlP5.ControlGroup;
import controlP5.ControlP5;
import controlP5.Controller;
import controlP5.ListBox;
import controlP5.Tab;
import de.fuberlin.processing.who.cancer.data.DBException;
import de.fuberlin.processing.who.cancer.data.Database;
import de.fuberlin.processing.who.cancer.data.DatabaseConnector;
import de.fuberlin.processing.who.cancer.interaction.LocationBroadcaster;
import de.fuberlin.processing.who.cancer.interaction.LocationModifier;
import de.fuberlin.processing.who.cancer.run.CancerSketch;


public class AdditinalInfomationSelector extends Controller {

	public static final int NUM_GRAPH_WIDTH = CancerSketch.NUM_SKETCH_WIDTH
			- HealthGraph.NUM_GRAPH_WIDTH - 3 * CancerSketch.NUM_SKETCH_PADDING;
	public static final int NUM_GRAPH_HEIGHT = CancerSketch.NUM_SKETCH_HEIGHT
			- Scatterplot.NUM_PLOT_HEIGHT - 2*CancerSketch.NUM_SKETCH_PADDING
			- ParameterMenu.NUM_LIST_HEIGHT;
	private int left;
	private int top;
	private DatabaseConnector db;
	private ListBox additionalGraphsMenu;
	private ControlGroup controlGroup;

	public AdditinalInfomationSelector(ControlP5 theControlP5, String theName, int theX,
			int theY) {
		super(theControlP5, (Tab) (theControlP5.getTab("default")), theName,
				theX, theY, NUM_GRAPH_WIDTH, NUM_GRAPH_HEIGHT);
		this.left = theX;
		this.top = theY;
		
		initControlGroup();
		initMenu();

		connectToDatabase();
		this.getCaptionLabel().setVisible(false);
	}
	
	private void initControlGroup() {
		controlGroup = controlP5.addGroup( "additinalInformationSelectorControlGroup", (int) this.position.x, (int) this.position.y,
				this.getWidth());
		controlGroup.hideBar();
		controlGroup.setHeight( this.getHeight());
		controlGroup.addCanvas( new ControlCanvas() {
			@Override
			public void draw( PApplet p) {
				p.pushStyle();
				p.fill( 0);
				p.rect( 0, 0, controlGroup.getWidth(), controlGroup.getHeight());
				p.popStyle();
			}
		});
		
		controlGroup.setHeight( 600);
		
	//	controlGroup.

	}
	
	private void initMenu() {
		additionalGraphsMenu = new ListBox( controlP5, controlGroup, "additinalInformationMenu", 0, 0, width, height);  //controlP5.addListBox( "myList",100,100,120,120);
	  additionalGraphsMenu.setItemHeight(15);
	  additionalGraphsMenu.setBarHeight(15);
	  additionalGraphsMenu.addItem( "11111111", 1);
	 // additionalGraphsMenu.setB
	  controlGroup.add( additionalGraphsMenu);
	  controlP5.register( additionalGraphsMenu);
	}

	private void connectToDatabase() {
		try {
			db = Database.get();
		} catch (DBException e) {
			e.printStackTrace();
		}
	}

	

	
	// overwrite the draw method for the controller's visual representation.
	public void draw(PApplet p) {
	  p.rectMode(p.CORNER);
		p.fill(55);
		p.rect(left, top, NUM_GRAPH_WIDTH, NUM_GRAPH_HEIGHT);
	}

	@Override
	public Controller setValue(float theValue) {
		// TODO Auto-generated method stub
		return null;
	}



}
